package com.ruoyi.project.anfang.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.anfang.domain.GongZhong;
import com.ruoyi.project.anfang.service.IGongZhongService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 公众号管理Controller
 * 
 * @author chendg
 * @date 2025-04-17
 */
@Api(tags = "后端管理/公众号管理")
@RestController
@RequestMapping("/anfang/gongzhong")
public class GongZhongController extends BaseController
{
    @Autowired
    private IGongZhongService gongZhongService;

    /**
     * 查询公众号管理列表
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:list')")
    @GetMapping("/list")
    @ApiOperation("公众号管理--列表")
    public TableDataInfo list(GongZhong gongZhong)
    {
        startPage();
        List<GongZhong> list = gongZhongService.selectGongZhongList(gongZhong);
        return getDataTable(list);
    }

    /**
     * 导出公众号管理列表
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:export')")
    @Log(title = "公众号管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("公众号管理--导出")
    public void export(HttpServletResponse response, GongZhong gongZhong)
    {
        List<GongZhong> list = gongZhongService.selectGongZhongList(gongZhong);
        ExcelUtil<GongZhong> util = new ExcelUtil<GongZhong>(GongZhong.class);
        util.exportExcel(response, list, "公众号管理数据");
    }

    /**
     * 获取公众号管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("公众号管理--详情")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gongZhongService.selectGongZhongById(id));
    }

    /**
     * 新增公众号管理
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:add')")
    @Log(title = "公众号管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("公众号管理--添加")
    public AjaxResult add(@RequestBody GongZhong gongZhong)
    {
        return toAjax(gongZhongService.insertGongZhong(gongZhong));
    }

    /**
     * 修改公众号管理
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:edit')")
    @Log(title = "公众号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("公众号管理--修改")
    public AjaxResult edit(@RequestBody GongZhong gongZhong)
    {
        return toAjax(gongZhongService.updateGongZhong(gongZhong));
    }

    /**
     * 删除公众号管理
     */
//    @PreAuthorize("@ss.hasPermi('anfang:gongzhong:remove')")
    @Log(title = "公众号管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("公众号管理--删除")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gongZhongService.deleteGongZhongByIds(ids));
    }
}
